package lesson04;

public class People {
    public String name;
    public int age;
    public People(){
        // 调用当前类的其他构造方法
        // this()必须写在构造方法第一句
        this("小二",30);
        // 构造方法：
        // 作用是产生对象并初始化属性
        // 构造方法特点：
        // 1. 名字和类名一样
        // 2. 没有返回值类型和void
        // 一个类默认存在一个无参的构造方法
        // 如果写了一个有参构造方法，那么无参的就会被覆盖掉
    }
    public People(String name,int age){
        this.name = name;
        this.age = age;
    }
    public void intro(){
        String name = "hello";
        System.out.println(this.name);
        System.out.println("我是" + this.name + "，今年"+ this.age +"岁");
    }

    public static void main(String[] args) {
        People people1 = new People("张飞",20);
        people1.intro();
        People people2 = new People("关羽",30);
        people2.intro();
        People people3 = new People();
        people3.intro();
    }
}
